//
//  showImageView.m
//  testCocoPods1.0
//
//  Created by ChenJs92 on 16/11/16.
//  Copyright © 2016年 chenjs92. All rights reserved.
//

#import "showImageView.h"
#import "MVShowImageViewModel.h"
#import "MVSecendScrooViewDataModel.h"
@interface showImageView()
@property (strong, nonatomic) UIImageView *baseImageView;
@property (strong, nonatomic) MVShowImageViewModel *viewModel;
@end

@implementation showImageView
-(instancetype)initWithViewModel:(id<MVViewModelProtocol>)viewModel{
    self.viewModel = (MVShowImageViewModel *)viewModel;
    return [super initWithViewModel:viewModel];
}
-(void)updateConstraints{
    WS(weakSelf);
   [self.baseImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       make.edges.mas_equalTo(weakSelf);
   }];
    [super updateConstraints];
}
#pragma mark - private
- (void)yd_setupViews {
    [self addSubview:self.baseImageView];
    [self setNeedsUpdateConstraints];
    [self updateConstraintsIfNeeded];
}
-(void)yd_bindViewModel{
    
    [self setActiList];
}
-(void)setActiList{
    NSLog(@"绘制imageView----------");
    NSDictionary *dataDic = self.viewModel.dataDic;
    MVSecendScrooViewDataModel *model = (MVSecendScrooViewDataModel *)dataDic[@"image"];
    NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",model.banaImageName]];
    [_baseImageView sd_setImageWithURL:imageUrl];
}
-(MVShowImageViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[MVShowImageViewModel alloc] init];
    }
    return _viewModel;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.viewModel.showOrHidenNavBarSubject sendNext:nil];
}
-(UIImageView *)baseImageView{
    if (!_baseImageView) {
        _baseImageView = [[UIImageView alloc] init];
        _baseImageView.backgroundColor = [UIColor colorWithRed:0.502 green:0.000 blue:0.251 alpha:1.000];
        _baseImageView.contentMode = UIViewContentModeScaleAspectFit;
//        _baseImageView.userInteractionEnabled = YES;
//        UITapGestureRecognizer *gender = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(<#selector#>)];
    }
    return _baseImageView;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
